import axios from "axios"
import { Promise } from "core-js";
const request = axios.create({
    baseURL:"http://127.0.0.1:8117",
    timeout:5000
})
 
//reques请求拦截器
request.interceptors.request.use(config => {
    config.headers['Content-Type']='application/json;charset=utf-8';
    return config;
},
   erro => {
       return Promise.reject(erro)
   }
);
//response拦截器
request.interceptors.response.use(response => {
    let res = response.data;
    //返回文件
    if(response.config.responseType=='blob'){
        return res;
    }
    //字符串处理
    if(typeof res == 'string'){
        res = res ? JSON.parse(res) : res;
    }
    return res;
},erro => {
     console.log('erro'+erro);
     return Promise.reject(erro);
}
);
 
export default request